<?php
class admin_model_user_admin_log extends model
{

    public function get_logs($key, $success = -1, $offset = 0, $limit = 20)
    {
        $query = 'SELECT * FROM `bone_user_admin_log` WHERE 1 ';
        if ($key !== '') $query .= ' AND `username` LIKE \'%' . $key . '%\'';
        if ($success != -1) $query .= ' AND `success`=' . $success;
        
        $query .= ' ORDER BY `id` DESC';
        
        $db = bone::get_db();
        return $db->get_objs($query, $offset, $limit);
    }
    
    public function get_log_sum($key, $success = -1)
    {
        $query = 'SELECT COUNT(*) FROM `bone_user_admin_log` WHERE 1 ';
        if ($key !== '') $query .= ' AND `username` LIKE \'%' . $key . '%\'';
        if ($success != -1) $query .= ' AND `success`=' . $success;
        $db = bone::get_db();
        return $db->get_result($query);
    }

}
?>